<template>
  <div id="main-search" class="main-search">
    <el-form
      :model="model"
      ref="commonForm"
      inline
      label-width="auto"
      class="demo-ruleForm"
    >
      <el-row :gutter="15">
        <el-col v-for="item in itemList" :key="item.prop" :span="item.span">
          <el-form-item class="item" :label="item.label" :prop="item.prop">
            <el-input
              v-if="item.type === 'Input'"
              clearable
              v-model.trim="model[item.prop]"
              :placeholder="item.placeholder"
            />
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-button
            v-for="item in searchBtn"
            :key="item.label"
            :icon="item.icon"
            :type="item.type"
            v-has="item.has"
            :disabled="item.disabled"
            @click="item.handle()"
          >
            {{ item.label }}
          </el-button>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import { Treeselect } from "@riophae/vue-treeselect"
// import the styles
import "@riophae/vue-treeselect/dist/vue-treeselect.css"
export default {
  components: {
    Treeselect
  },
  props: {
    model: {
      type: Object,
      default: () => {}
    },
    itemList: {
      type: Array,
      default: () => []
    },
    searchBtn: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {}
  },
  methods: {
    // 延迟加载
    // getLoadOptions() {
    //   this.$emit("loadOptions", action, parentNode, callback)
    // },
    // normalizer(node) {
    //   return {
    //     id: node.key,
    //     label: node.name,
    //     children: node.subOptions
    //   }
    // }
  }
}
</script>
<style lang="scss" scoped>
.main-search {
  .el-row {
    display: flex;
    flex-wrap: wrap;
  }
  .item {
    width: 100%;
    display: flex;
    /deep/.el-form-item__content {
      flex: 1;
    }
  }
}
</style>
